<template>
  <el-card class="app-container">
    <c-u-r-d-table :option="option" ref="table"/>
  </el-card>
</template>

<script>

import ColumnType from '@/framework/constant/ColumnType'
import {projectSpotApi} from '@/feature/mj/infra/api/projectSpotApi'
import CURDTable from '@/framework/components/table/CURDTable'
import {scenicSpotTagApi} from "@/feature/mj/infra/api/scenicSpotTagApi";

export default {
  components: {CURDTable},
  name: 'ProjectSpot',
  props: {
    projectId: {
      type: Number,
      default: 0
    }
  },
  data() {
    return {
      option: {
        autoLoad: false,
        initListParams: () => {
          return {
            projectId: this.projectId
          }
        },
        initFormParams: () => {
          return {
            projectId: this.projectId
          }
        },
        tableHeight: 500,
        requestApi: projectSpotApi,
        showSelection: false,
        loadDetail: true,
        groupId: 2,
        columns: [
          {
            label: '景点名称',
            searchable: true,
            required: true,
            span: 24,
            prop: 'name'
          },
          {
            label: '封面',
            type: ColumnType.IMAGE,
            required: true,
            width: 80,
            span: 24,
            prop: 'cover'
          },
          {
            label: '景点地址',
            prop: 'address',
            required: true,
            span: 24,
            type: ColumnType.TEXTAREA
          },
          {
            label: '经度',
            required: true,
            prop: 'longitude',
            width: 100,
            type: ColumnType.NUMBER,
            renderOptions: {
              precision: 6,
              max: 180,
              min: 0
            }
          },
          {
            label: '纬度',
            required: true,
            width: 100,
            type: ColumnType.NUMBER,
            renderOptions: {
              precision: 6,
              max: 90,
              min: 0
            },
            prop: 'latitude'
          },
          {
            label: '标签',
            required: false,
            span: 24,
            hiddenInTable: true,
            type: ColumnType.MUL_SELECT,
            prop: 'tagIdList',
            dataType: 'array',
            options: scenicSpotTagApi.listAll()
          },
          {
            label: '图片',
            span: 24,
            hiddenInTable: true,
            required: true,
            type: ColumnType.IMAGE,
            limit: 10,
            prop: 'photoList',
            dataType: 'array'
          }, {
            label: '内容',
            type: ColumnType.RICH_EDITOR,
            required: true,
            hiddenInTable: true,
            span: 24,
            prop: 'intro'
          },
          {
            label: '创建时间',
            type: ColumnType.DATETIME,
            hiddenInForm: true,
            prop: 'gmtCreate'
          },
          {
            label: '修改时间',
            type: ColumnType.DATETIME,
            hiddenInForm: true,
            prop: 'gmtModified'
          }
        ]
      }
    }
  },
  methods: {
    refresh() {
      this.$refs.table.reloadTable()
    }
  }
}
</script>

